%s lexicon
%s header
%s body

ws [ \t]+
z {ws}?([0-9]*[.])?[0-9]+{ws}[0-9]+{ws}

plosive p|b|t|d|k|g
affricate pf|ts|tS|dZ
fricative f|v|s|z|S|Z|C|j|x|h
nasal N|m|n
liquid l|R
consonant {plosive}|{affricate}|{fricative}|{nasal}|{liquid}
shortvowel I|E|a|O|U|Y|9
longvowel i:|e:|E:|a:|o:|u:|y:|2:
diphtong aI|aU|OY
schwa @|6
vowel {shortvowel}|{longvowel}|{diphtong}|{schwa}
marker \[|\]|\"

%%

^signal{ws}        {/* This file is a waves label file */ 
                   BEGIN(header);}
<header>^\#{ws}?\n BEGIN(body);
<header>[^#]       /* don't printout rest of header */
<body>{z}          /*ignore time info */
<body>\n           /*ignore newline*/

^[^\\]/\\          {/* this file is a lexiconfile (delimiter='\') */ 
                   printf("Word----- %s -----\n",yytext);BEGIN(lexicon);}
<lexicon>\n.*/\\   printf("Word----- %s -----\n",yytext+1);
<lexicon>\\        /*ignore*/

\<[^>]*\>          printf("Extra          :\t%s\n",yytext);
{plosive}          printf("Plosive        :\t%s\n",yytext);
%{
/*Affricates are NOT treated special (and hence commented)
{affricate}        printf("Affricate      :\t%s\n",yytext);
*/
%}
{fricative}        printf("Fricative      :\t%s\n",yytext);
{nasal}            printf("Nasal          :\t%s\n",yytext);
{liquid}           printf("Liquid         :\t%s\n",yytext);
{shortvowel}       printf("ShortVowel     :\t%s\n",yytext);
{longvowel}        printf("LongVowel      :\t%s\n",yytext);
{diphtong}         printf("Diphtong       :\t%s\n",yytext);
{schwa}            printf("Schwa          :\t%s\n",yytext);
{marker}           printf("Marker         :\t%s\n",yytext);
(A|O|\{|9)~:?      printf("NasalizedVowel :\t%s\n",yytext);
={consonant}       printf("SyllabicCons   :\t%s\n",yytext);
{ws}               printf("WordBoundary   :\t#\n");
\r?\n              /* ignore (cr)lf */
.                  printf("###Unknown###  :\t%s\n",yytext);

%%
main(argc, argv)
int argc;
char **argv;
{
  int i;

  ++argv; --argc; /* skip over program name */

  if(argc>0){
    for(i=0; i<argc; i++){
      yyin = fopen(argv[i],"r");
      if (yyin==NULL) 
        fprintf(stderr,"could not open %s --- skipped.\n",argv[i]);
      else {
        yylex();
      }
    }
  } else {
    yyin=stdin;
    yylex();
  }
}
